<?php
namespace Common\Model;
use Think\Model;

class InfoCategoryModel extends Model{

	public function getCategory($pid){
		$map['pid'] = array('in',array(0,$pid));
		$category = $this->where($map)->field("category,directory,title,pid,id")->order('id')->select();
		return $category;
	}

	public function getCategoryById($id){
		$map['id'] = array('eq',$id);
		//$pid = $this->where($map)->order('id asc')->getField('pid'); //array("pid"=>array('eq',$pid))
		$category = $this->where($map)->field("category,directory,title,pid,id")->order('id')->select();
		return $category;
	}

	public function getFatherCategory($cid){
		return $this->where("id = $cid")->field("category,directory,title,pid,id")->find();
	}

	public function getCategoryByPid($pid){
		return $this->where("pid = $pid")->field("category,directory,title,pid,id")->select();
	}

	public function getAllCategory(){
		return $this->select();
	}

	public function getCategoryGroPid(){
		return $this->field("id,category,pid")->group('pid,id')->select();
	}
}
